import { defineStore } from "pinia";

import { piniaPersistConfig } from '@/utils/persist';

export const useGlobalStore = defineStore('globalState', {
    state: () => ({
        isCollapse: false,  // 侧边栏展开状态
        themeName: 'dark',  // 主题名称
    }) ,
    getters: {
        userName: (state) => {
            return state.userInfo?.user_name;
        }
    },
    actions: {
        toggleIsCollapse(){
            this.isCollapse = !this.isCollapse;
        },
        setThemeName(themeName){
            this.themeName = themeName;
        }
    },
    persist: piniaPersistConfig("globalState")
});
